import pandas as pd
from dao.SysDictDao import SysDictDao
from Static import Static


class SysDictService:
    def initDB(self):
        dao = SysDictDao()
        df = dao.getDict("sys_user_sex")
        if df.shape[0] == 0:
            list = []
            list.append({"dictLabel": "男", "dictValue": "1", "key": "sys_user_sex"})
            list.append({"dictLabel": "女", "dictValue": "2", "key": "sys_user_sex"})

            list.append(
                {"dictLabel": "正常", "dictValue": "1", "key": "sys_normal_disable"}
            )
            list.append(
                {"dictLabel": "停用", "dictValue": "0", "key": "sys_normal_disable"}
            )

            list.append({"dictLabel": "是", "dictValue": "1", "key": "sys_yes_no"})
            list.append({"dictLabel": "否", "dictValue": "0", "key": "sys_yes_no"})

            list.append(
                {
                    "dictLabel": "普通用户",
                    "dictValue": Static.ROLE_NORMAL,
                    "key": "sys_role",
                }
            )
            list.append(
                {
                    "dictLabel": "系统管理员",
                    "dictValue": Static.ROLE_ADMIN,
                    "key": "sys_role",
                }
            )
            df = pd.DataFrame(data=list, columns=list[0].keys())
            dao.initSysDict(df)

    def getDict(self, key):
        df = SysDictDao().getDict(key)
        return df
